/**
 * 描述：优先队列，使用Queue的接口，底层使用堆来实现
 *
 * @author WangB
 * 2018-10-22-19:49
 */
public class PriorityQueue<E extends Comparable<E>> implements Queue<E>{
    private MaxHeap<E> maxHeap;

    public PriorityQueue(){
        maxHeap = new MaxHeap <> ();
    }
    @Override
    public int getSize(){
        return maxHeap.size ();
    }

    @Override
    public boolean isEmpty(){
        return maxHeap.isEmpty ();
    }
    @Override
    public void enqueue(E e){
        maxHeap.add (e);
    }
    @Override
    public E dequeue(){
        return maxHeap.extractMax ();
    }

    @Override
    public E getFront(){
        return maxHeap.findMax ();
    }
}
